package com.xiongfan.jdbc.framework;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.*;

public class JdbcClassUtils {
    private JdbcClassUtils(){}
    private static final Set<Class<?>>SUPPORTED_SQL_OBJECTS =new HashSet<>();

    static {
        Class<?>[]classes ={
                boolean.class, Boolean.class,
                short.class, Short.class,
                int.class, Integer.class,
                long.class, Long.class,
                float.class, Float.class,
                double.class, Double.class,
                String.class,
                Date.class,
                Timestamp.class,
                BigDecimal.class
        };
        SUPPORTED_SQL_OBJECTS.addAll(Arrays.asList(classes));
    }

    static boolean isSupportedSQLObject(Class<?>clazz){
        return clazz.isEnum() || SUPPORTED_SQL_OBJECTS.contains(clazz);
    }

    /**
     * 获取类中所有public方法
     * @param clazz
     * @return
     */
    public static Map<String, Method> findPublicGetter(Class<?> clazz){
        Map<String, Method> map = new HashMap<String, Method>();
        Method[] methods=clazz.getMethods();
        for(Method method:clazz.getMethods()){
            if(Modifier.isStatic(method.getModifiers())){
                continue;
            }
        }
        return null;
    }

}
